package com.wman.learn.funcation

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel

/**
 * @ProjectName: wman
 * @Package: com.wman.learn.funcation
 * @ClassName: MyViewModel
 * @Description: java类作用描述
 * @Author: wman
 * @CreateDate: 2020/1/2 15:09
 * @UpdateUser: 更新者
 * @UpdateDate: 2020/1/2 15:09
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
class MyViewModel : ViewModel() {
    private val _number: MutableLiveData<Int> by lazy { MutableLiveData<Int>().also { it.value = 0 } }
//    val number = MutableLiveData(0)

//    }

    //    init {
//        number = MutableLiveData()
//        number.value = 0
    val number: LiveData<Int>
        get() = _number

    fun modifyNumber(aNumber: Int) {
        _number.value = _number.value?.plus(aNumber)
    }
}